package GUI;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.border.EmptyBorder;

import ENTITAETEN.Konzert;

public class Hauptfenster extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField textField_6;
	private JTextField textField_7;
	private JTextField textField_8;
	private JTextField textField_9;
	private JTextField textField_10;
	private JTextField textField_11;
	private JTextField textField_12;
	private JTextField textField_13;
	private JTextField textField_14;
	private JTextField textField_15;
	private JTextField textField_16;
	private JTextField textField_17;
	private JTextField textField_18;
	private JTextField textField_19;
	private JTextField textField_20;
	private JTextField textField_21;
	private JTextField textField_22;
	private JTextField textField_23;
	private JTextField textField_24;
	private JTextField textField_25;
	private JTextField textField_26;
	private JTextField textField_27;
	private JTextField textField_28;
	private JTextField textField_29;
	private JTextField textField_30;
	private JTextField textField_31;
	private JTextField textField_32;
	private JTextField textField_33;
	private JSpinner spinner_12;
	private JSpinner spinner_13;
	private JCheckBox chckbxGema;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Hauptfenster frame = new Hauptfenster();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Hauptfenster() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 753, 739);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblKonzert = new JLabel("Konzert");
		lblKonzert.setBounds(10, 11, 46, 14);
		contentPane.add(lblKonzert);
		
		JComboBox comboBox = new JComboBox();
		comboBox.setBounds(10, 36, 717, 20);
		contentPane.add(comboBox);
		
		textField = new JTextField();
		textField.setBounds(63, 64, 182, 20);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel lblDatum = new JLabel("Datum");
		lblDatum.setBounds(10, 67, 46, 14);
		contentPane.add(lblDatum);
		
		JLabel lblBand = new JLabel("Band 1");
		lblBand.setBounds(10, 166, 46, 14);
		contentPane.add(lblBand);
		
		textField_1 = new JTextField();
		textField_1.setBounds(63, 163, 182, 20);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel lblBand_1 = new JLabel("Band 2");
		lblBand_1.setBounds(10, 197, 46, 14);
		contentPane.add(lblBand_1);
		
		JLabel lblBand_2 = new JLabel("Band 3");
		lblBand_2.setBounds(10, 228, 46, 14);
		contentPane.add(lblBand_2);
		
		JLabel lblBand_3 = new JLabel("Band 4");
		lblBand_3.setBounds(10, 259, 46, 14);
		contentPane.add(lblBand_3);
		
		JLabel lblBand_4 = new JLabel("Band 5");
		lblBand_4.setBounds(10, 293, 46, 14);
		contentPane.add(lblBand_4);
		
		JLabel lblBand_5 = new JLabel("Band 6");
		lblBand_5.setBounds(10, 327, 46, 14);
		contentPane.add(lblBand_5);
		
		textField_2 = new JTextField();
		textField_2.setColumns(10);
		textField_2.setBounds(63, 194, 182, 20);
		contentPane.add(textField_2);
		
		textField_3 = new JTextField();
		textField_3.setColumns(10);
		textField_3.setBounds(63, 225, 182, 20);
		contentPane.add(textField_3);
		
		textField_4 = new JTextField();
		textField_4.setColumns(10);
		textField_4.setBounds(63, 256, 182, 20);
		contentPane.add(textField_4);
		
		textField_5 = new JTextField();
		textField_5.setColumns(10);
		textField_5.setBounds(63, 290, 182, 20);
		contentPane.add(textField_5);
		
		textField_6 = new JTextField();
		textField_6.setColumns(10);
		textField_6.setBounds(63, 324, 182, 20);
		contentPane.add(textField_6);
		
		JLabel lblKonzertname = new JLabel("Konzertname");
		lblKonzertname.setBounds(255, 67, 86, 14);
		contentPane.add(lblKonzertname);
		
		textField_7 = new JTextField();
		textField_7.setBounds(348, 64, 379, 20);
		contentPane.add(textField_7);
		textField_7.setColumns(10);
		
		JLabel lblBand_6 = new JLabel("Band");
		lblBand_6.setBounds(10, 141, 46, 14);
		contentPane.add(lblBand_6);
		
		JLabel lblBandnamen = new JLabel("Bandnamen");
		lblBandnamen.setBounds(63, 138, 182, 14);
		contentPane.add(lblBandnamen);
		
		JLabel lblFestgage = new JLabel("Festgage");
		lblFestgage.setBounds(259, 141, 82, 14);
		contentPane.add(lblFestgage);
		
		textField_8 = new JTextField();
		textField_8.setBounds(255, 163, 86, 20);
		contentPane.add(textField_8);
		textField_8.setColumns(10);
		
		textField_9 = new JTextField();
		textField_9.setColumns(10);
		textField_9.setBounds(255, 194, 86, 20);
		contentPane.add(textField_9);
		
		textField_10 = new JTextField();
		textField_10.setColumns(10);
		textField_10.setBounds(255, 225, 86, 20);
		contentPane.add(textField_10);
		
		textField_11 = new JTextField();
		textField_11.setColumns(10);
		textField_11.setBounds(255, 256, 86, 20);
		contentPane.add(textField_11);
		
		textField_12 = new JTextField();
		textField_12.setColumns(10);
		textField_12.setBounds(255, 290, 86, 20);
		contentPane.add(textField_12);
		
		textField_13 = new JTextField();
		textField_13.setColumns(10);
		textField_13.setBounds(255, 324, 86, 20);
		contentPane.add(textField_13);
		
		JLabel lblProzentual = new JLabel("Prozentual");
		lblProzentual.setBounds(348, 141, 66, 14);
		contentPane.add(lblProzentual);
		
		JSpinner spinner = new JSpinner();
		spinner.setModel(new SpinnerNumberModel(0, 0, 100, 5));
		spinner.setBounds(351, 163, 53, 20);
		contentPane.add(spinner);
		
		JSpinner spinner_1 = new JSpinner();
		spinner_1.setModel(new SpinnerNumberModel(0, 0, 100, 5));
		spinner_1.setBounds(351, 195, 53, 20);
		contentPane.add(spinner_1);
		
		JSpinner spinner_2 = new JSpinner();
		spinner_2.setModel(new SpinnerNumberModel(0, 0, 100, 5));
		spinner_2.setBounds(351, 226, 53, 20);
		contentPane.add(spinner_2);
		
		JSpinner spinner_3 = new JSpinner();
		spinner_3.setModel(new SpinnerNumberModel(0, 0, 100, 5));
		spinner_3.setBounds(351, 257, 53, 20);
		contentPane.add(spinner_3);
		
		JSpinner spinner_4 = new JSpinner();
		spinner_4.setModel(new SpinnerNumberModel(0, 0, 100, 5));
		spinner_4.setBounds(351, 291, 53, 20);
		contentPane.add(spinner_4);
		
		JSpinner spinner_5 = new JSpinner();
		spinner_5.setModel(new SpinnerNumberModel(0, 0, 100, 5));
		spinner_5.setBounds(351, 325, 53, 20);
		contentPane.add(spinner_5);
		
		JLabel lblProzentualAbBreak = new JLabel("Prozentual ab Break");
		lblProzentualAbBreak.setBounds(439, 141, 143, 14);
		contentPane.add(lblProzentualAbBreak);
		
		Component verticalStrut = Box.createVerticalStrut(20);
		verticalStrut.setBounds(414, 160, 12, 181);
		contentPane.add(verticalStrut);
		
		JSpinner spinner_6 = new JSpinner();
		spinner_6.setBounds(439, 164, 104, 20);
		contentPane.add(spinner_6);
		
		JSpinner spinner_7 = new JSpinner();
		spinner_7.setBounds(439, 191, 104, 20);
		contentPane.add(spinner_7);
		
		JSpinner spinner_8 = new JSpinner();
		spinner_8.setBounds(439, 222, 104, 20);
		contentPane.add(spinner_8);
		
		JSpinner spinner_9 = new JSpinner();
		spinner_9.setBounds(439, 257, 104, 20);
		contentPane.add(spinner_9);
		
		JSpinner spinner_10 = new JSpinner();
		spinner_10.setBounds(439, 291, 104, 20);
		contentPane.add(spinner_10);
		
		JSpinner spinner_11 = new JSpinner();
		spinner_11.setBounds(439, 325, 104, 20);
		contentPane.add(spinner_11);
		
		JLabel lblAusgaben = new JLabel("Ausgaben");
		lblAusgaben.setFont(new Font("Segoe UI", Font.BOLD, 16));
		lblAusgaben.setBounds(10, 352, 111, 29);
		contentPane.add(lblAusgaben);
		
		JLabel lblAusgaben_1 = new JLabel("Ausgaben");
		lblAusgaben_1.setBounds(573, 141, 66, 14);
		contentPane.add(lblAusgaben_1);
		
		textField_14 = new JTextField();
		textField_14.setBounds(571, 163, 88, 20);
		contentPane.add(textField_14);
		textField_14.setColumns(10);
		
		textField_15 = new JTextField();
		textField_15.setColumns(10);
		textField_15.setBounds(573, 194, 86, 20);
		contentPane.add(textField_15);
		
		textField_16 = new JTextField();
		textField_16.setColumns(10);
		textField_16.setBounds(573, 225, 86, 20);
		contentPane.add(textField_16);
		
		textField_17 = new JTextField();
		textField_17.setColumns(10);
		textField_17.setBounds(573, 256, 86, 20);
		contentPane.add(textField_17);
		
		textField_18 = new JTextField();
		textField_18.setColumns(10);
		textField_18.setBounds(573, 290, 86, 20);
		contentPane.add(textField_18);
		
		textField_19 = new JTextField();
		textField_19.setColumns(10);
		textField_19.setBounds(573, 324, 86, 20);
		contentPane.add(textField_19);
		
		JLabel lblBand_7 = new JLabel("Bands");
		lblBand_7.setBounds(10, 392, 76, 14);
		contentPane.add(lblBand_7);
		
		textField_20 = new JTextField();
		textField_20.setBounds(96, 390, 149, 20);
		contentPane.add(textField_20);
		textField_20.setColumns(10);
		
		JLabel lblMiete = new JLabel("Miete");
		lblMiete.setBounds(10, 424, 77, 14);
		contentPane.add(lblMiete);
		
		textField_21 = new JTextField();
		textField_21.setColumns(10);
		textField_21.setBounds(97, 421, 149, 20);
		contentPane.add(textField_21);
		
		textField_22 = new JTextField();
		textField_22.setColumns(10);
		textField_22.setBounds(97, 452, 149, 20);
		contentPane.add(textField_22);
		
		JLabel lblEssen = new JLabel("Essen");
		lblEssen.setBounds(10, 548, 77, 14);
		contentPane.add(lblEssen);
		
		textField_23 = new JTextField();
		textField_23.setColumns(10);
		textField_23.setBounds(97, 483, 149, 20);
		contentPane.add(textField_23);
		
		JLabel lblTrinken = new JLabel("Trinken");
		lblTrinken.setBounds(9, 573, 77, 14);
		contentPane.add(lblTrinken);
		
		textField_24 = new JTextField();
		textField_24.setColumns(10);
		textField_24.setBounds(96, 514, 149, 20);
		contentPane.add(textField_24);
		
		JLabel lblFrhstck = new JLabel("Fr\u00FChst\u00FCck");
		lblFrhstck.setBounds(10, 606, 76, 14);
		contentPane.add(lblFrhstck);
		
		chckbxGema = new JCheckBox("Gema");
		chckbxGema.setBounds(6, 631, 80, 25);
		contentPane.add(chckbxGema);
		
		textField_25 = new JTextField();
		textField_25.setColumns(10);
		textField_25.setBounds(96, 545, 149, 20);
		contentPane.add(textField_25);
		
		JLabel lblZusammen = new JLabel("Zusammen");
		lblZusammen.setBounds(10, 667, 76, 14);
		contentPane.add(lblZusammen);
		
		textField_26 = new JTextField();
		textField_26.setColumns(10);
		textField_26.setBounds(96, 572, 149, 20);
		contentPane.add(textField_26);
		
		JLabel lblDeals = new JLabel("Deals");
		lblDeals.setFont(new Font("Segoe UI", Font.BOLD, 16));
		lblDeals.setBounds(10, 101, 111, 29);
		contentPane.add(lblDeals);
		
		JLabel lblEinnahmen = new JLabel("Einnahmen");
		lblEinnahmen.setFont(new Font("Segoe UI", Font.BOLD, 16));
		lblEinnahmen.setBounds(255, 355, 111, 29);
		contentPane.add(lblEinnahmen);
		
		JLabel lblAnlange = new JLabel("Anlange");
		lblAnlange.setBounds(10, 455, 46, 14);
		contentPane.add(lblAnlange);
		
		JLabel lblLicht = new JLabel("T\u00FCrsteher");
		lblLicht.setBounds(10, 517, 76, 14);
		contentPane.add(lblLicht);
		
		JLabel label = new JLabel("Licht");
		label.setBounds(10, 486, 46, 14);
		contentPane.add(label);
		
		textField_27 = new JTextField();
		textField_27.setColumns(10);
		textField_27.setBounds(96, 603, 149, 20);
		contentPane.add(textField_27);
		
		textField_28 = new JTextField();
		textField_28.setColumns(10);
		textField_28.setBounds(96, 633, 149, 20);
		contentPane.add(textField_28);
		
		textField_29 = new JTextField();
		textField_29.setColumns(10);
		textField_29.setBounds(96, 664, 149, 20);
		contentPane.add(textField_29);
		
		JLabel lblVvk = new JLabel("VVK");
		lblVvk.setBounds(259, 393, 53, 14);
		contentPane.add(lblVvk);
		
		spinner_12 = new JSpinner();
		spinner_12.setModel(new SpinnerNumberModel(new Integer(0), null, null, new Integer(1)));
		spinner_12.setBounds(338, 390, 75, 20);
		contentPane.add(spinner_12);
		
		JLabel lblPreis = new JLabel("Preis");
		lblPreis.setBounds(420, 392, 43, 14);
		contentPane.add(lblPreis);
		
		textField_30 = new JTextField();
		textField_30.setBounds(475, 389, 86, 20);
		contentPane.add(textField_30);
		textField_30.setColumns(10);
		
		JLabel lblGebhren = new JLabel("Geb\u00FChren pro Ticket");
		lblGebhren.setBounds(255, 421, 171, 14);
		contentPane.add(lblGebhren);
		
		textField_31 = new JTextField();
		textField_31.setColumns(10);
		textField_31.setBounds(475, 421, 86, 20);
		contentPane.add(textField_31);
		
		JLabel lblAk = new JLabel("AK");
		lblAk.setBounds(255, 456, 66, 14);
		contentPane.add(lblAk);
		
		spinner_13 = new JSpinner();
		spinner_13.setBounds(338, 453, 75, 20);
		contentPane.add(spinner_13);
		
		JLabel label_1 = new JLabel("Preis");
		label_1.setBounds(422, 455, 46, 14);
		contentPane.add(label_1);
		
		textField_32 = new JTextField();
		textField_32.setColumns(10);
		textField_32.setBounds(475, 452, 86, 20);
		contentPane.add(textField_32);
		
		JLabel lblGesamteinahmen = new JLabel("Gesamteinahmen");
		lblGesamteinahmen.setBounds(255, 487, 136, 14);
		contentPane.add(lblGesamteinahmen);
		
		textField_33 = new JTextField();
		textField_33.setColumns(10);
		textField_33.setBounds(475, 483, 86, 20);
		contentPane.add(textField_33);
		
		JLabel lblAbrechnung = new JLabel("Abrechnung");
		lblAbrechnung.setFont(new Font("Segoe UI", Font.BOLD, 16));
		lblAbrechnung.setBounds(255, 518, 111, 29);
		contentPane.add(lblAbrechnung);
		
		JLabel lblNewLabel = new JLabel("0\u20AC");
		lblNewLabel.setFont(new Font("Segoe UI", Font.BOLD, 16));
		lblNewLabel.setBounds(380, 525, 46, 14);
		contentPane.add(lblNewLabel);
		
		JButton btnRefresh = new JButton("Refresh");
		btnRefresh.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				aktualisereEditFenster();
			}
		});
		btnRefresh.setBounds(255, 569, 89, 23);
		contentPane.add(btnRefresh);
		
		JButton btnCommit = new JButton("Commit");
		btnCommit.setBounds(255, 602, 89, 23);
		contentPane.add(btnCommit);
	}
	
	public static int getBandAusgaben()
	{
		return 0;
	}
	
	public int getFesteAusgaben()
	{
		return 0;
	}
	
	public double getMiete()
	{
		return Double.parseDouble(this.textField_21.getText().replaceAll(",", "."));
	}
	
	public double getAnlagenMiete()
	{
		return Double.parseDouble(this.textField_22.getText().replaceAll(",", "."));
	}
	
	public double getLichtMiete()
	{
		return Double.parseDouble(this.textField_23.getText().replaceAll(",", "."));
	}
	
	public double getPreisFuerDenTuersteher()
	{
		return Double.parseDouble(this.textField_24.getText().replaceAll(",", "."));
	}
	
	public double getPreisFuerEssen()
	{
		return Double.parseDouble(this.textField_25.getText().replaceAll(",", "."));
	}
	
	public double getPreisFuerTrinken()
	{
		return Double.parseDouble(this.textField_26.getText().replaceAll(",", "."));
	}
	
	public double getPreisFuerFruehstueck()
	{
		return Double.parseDouble(this.textField_27.getText().replaceAll(",", "."));
	}
	
	public double getGemaGebuehren()
	{
		if (chckbxGema.isEnabled())
		{
			return getEinnahmen()*0.076;
		}
		return 0;
	}
	
	public double getVVK()
	{
		//TODO
		return 0;
	}
	
	public double getAK()
	{
		//TODO 
		return 0;
	}
	
	public double getEinnahmen()
	{
		int anzahlVVK = (int) this.spinner_12.getModel().getValue();
		double preisproticket = Double.parseDouble(this.textField_30.getText().replaceAll(",", "."));
		double gebuerhrenproticket = Double.parseDouble(this.textField_32.getText().replaceAll(",", "."));
		int anzahlAK = (int) this.spinner_13.getModel().getValue();
		double preisproTicketAK = Double.parseDouble(this.textField_32.getText().replaceAll(",", "."));
		return anzahlVVK*(preisproticket-gebuerhrenproticket)+anzahlAK*preisproTicketAK;
	}
	
	public void aktualisereEditFenster()
	{
		this.textField_33.setText(getEinnahmen()+"");
	}
	
	public void schreibeGUI(Konzert konzert)
	{
		textField.setText(konzert.datumDesKonzerts.getDay() + "." + konzert.datumDesKonzerts.getMonth() + "." + konzert.datumDesKonzerts.getYear());
		textField_7.setText(konzert.)
	}
}
